import os.path
from pathlib import Path


def get_project_root() -> Path:
    current_path = Path(os.path.dirname(os.path.abspath(__file__)))
    marker = "pyproject.toml"
    while not current_path.joinpath(marker).exists():
        current_path = current_path.parent
        if current_path == current_path.parent:
            raise FileNotFoundError(f"未找到项目根目录，缺少 {marker} 文件！")
    return Path(current_path)

get_project_root = get_project_root()
if __name__ == '__main__':
    print(get_project_root)